package com.example.cal_manage;

import android.app.Activity;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Window;

public class SplashActivity extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.splash);
		Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			Intent intent;
			@Override
			public void run() {
				MyOpenHelper helper = new MyOpenHelper(getApplicationContext());
				SQLiteDatabase db = helper.getWritableDatabase();

				try{
					Cursor c = db.rawQuery("select Gender from DefaultSettings;",new String[]{});
					if(c.moveToNext()){
						intent = new Intent(SplashActivity.this,MainActivity.class);
					}else{
						intent = new Intent(SplashActivity.this,Syoki_settei.class);
					}
				}catch(Exception e){
					Log.e("Splash", "DB");
				}finally{
					db.close();
				}

				startActivity(intent);
				finish();
			}
		}, 2000);
	}
}
